package com.bawei.arouter

import android.content.Context
import android.util.Log
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.DegradeService

/**
 * Author: Jason Zhang
 * Date: 2024/4/26
 * Desc: 全局的降级策略
 * 注意：走全局的降级策略，必须传入上下文
 */
@Route(path = "/degrade/service")
class GlobalDegradeService : DegradeService{

    private lateinit var mContext: Context

    override fun init(context: Context) {
        mContext = context
    }

    override fun onLost(context: Context, postcard: Postcard) {
        Log.e("PageDegradeService", "Target Page: ${postcard.path} not found!!")
        postcard.path = "/empty/activity"
        postcard.navigation()
    }
}